#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct TreeNode
{
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

//对称的二叉树，递归
bool helper(TreeNode *p1, TreeNode *p2)
{
    if (!p1 && !p2)
    {
        return true;
    }
    if (!p1 && p2 || p1 && !p2)
    {
        return false;
    }
    if (p1->val == p2->val)
    {
        return helper(p1->left, p2->right) && helper(p1->right, p2->left);
    }
    else
    {
        return false;
    }
}

bool isSymmetrical(TreeNode *pRoot)
{
    if (!pRoot)
    {
        return true;
    }
    return helper(pRoot->left, pRoot->right);
}

void test()
{
}

int main()
{
    test();
    return 0;
}